import { http } from '@/common/service/service.js'

// 成品出库相关API
export const finishedGoodsOutbound = {
  // 获取出库单列表
  getList: (params) => {
    return http.get('/wms/finished-goods/outbound/list', { params })
  },
  
  // 获取出库单详情
  getDetail: (id) => {
    return http.get(`/wms/finished-goods/outbound/detail/${id}`)
  },
  
  // 创建出库单
  create: (data) => {
    return http.post('/wms/finished-goods/outbound/add', data)
  },
  
  // 更新出库单
  update: (data) => {
    return http.put('/wms/finished-goods/outbound/edit', data)
  },
  
  // 删除出库单
  delete: (id) => {
    return http.delete(`/wms/finished-goods/outbound/delete/${id}`)
  },
  
  // 审核出库单
  approve: (id) => {
    return http.post(`/wms/finished-goods/outbound/approve/${id}`)
  },
  
  // 一键出库
  oneClickOutbound: (id) => {
    return http.post(`/wms/finished-goods/outbound/one-click-outbound/${id}`)
  },
  
  // 获取出库单明细库存列表
  getOutboundDetailList: (id) => {
    return http.get(`/wms/finished-goods/outbound/detail/outbountList/${id}`)
  }
}

// 成品库存相关API
export const finishedGoodsInventory = {
  // 获取库存列表
  getList: (params) => {
    return http.get('/wms/finished-goods/inventory/list', { params })
  },
  
  // 获取分层库存
  getHierarchicalList: (params) => {
    return http.get('/wms/finished-goods/inventory/hierarchical', { params })
  },
  
  // 根据订单查询库存
  getByOrder: (params) => {
    return http.get('/wms/finished-goods/inventory/by-order', { params })
  }
}

// 成品库存变更记录相关API
export const finishedGoodsInventoryLog = {
  // 获取库存变更记录列表
  getRecords: (params) => {
    return http.get('/wms/finished-goods/inventory-log/records', { params })
  },
  
  // 获取记录详情
  getDetail: (id) => {
    return http.get(`/wms/finished-goods/inventory-log/detail/${id}`)
  }
}

// 成品入库相关API
export const finishedGoodsInbound = {
  // 获取入库单列表
  getList: (params) => {
    return http.get('/wms/finished-goods/inbound/list', { params })
  },
  
  // 获取入库单详情
  getDetail: (id) => {
    return http.get(`/wms/finished-goods/inbound/detail/${id}`)
  },
  
  // 创建入库单
  create: (data) => {
    return http.post('/wms/finished-goods/inbound/add', data)
  },
  
  // 更新入库单
  update: (data) => {
    return http.put('/wms/finished-goods/inbound/edit', data)
  },
  
  // 删除入库单
  delete: (id) => {
    return http.delete(`/wms/finished-goods/inbound/delete/${id}`)
  },
  
  // 审核入库单
  approve: (id) => {
    return http.post(`/wms/finished-goods/inbound/approve/${id}`)
  },
  
  // 执行入库
  executeInbound: (data) => {
    return http.post('/wms/finished-goods/inbound/execute', data)
  }
}
